package com.example.mybank.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.mybank.entity.Users;
import com.example.mybank.mapper.UsersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UsersService {

    @Autowired
    UsersMapper usersMapper;

    public Users createAdmin(Users users){
        users.setIs_admin(Boolean.TRUE);
        users.setUsername("bank");
        users.setPassword("bank");
        usersMapper.insert(users);
        return users;
    }

    public Users getFirstAdmin(){
        QueryWrapper<Users> queryWrapper = new QueryWrapper();
        queryWrapper.eq("is_admin",Boolean.TRUE);
        return usersMapper.selectOne(queryWrapper);
    }
}
